package com.cn.jiyun.contoller;

import com.cn.jiyun.entity.pojo.Meals;
import com.cn.jiyun.entity.pojo.Vouchers;
import com.cn.jiyun.service.FoodService;

import com.cn.jiyun.entity.pojo.Food;
import com.jiyun.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【-Hotel】操作接口
 *
 * @author lxy
 * @since 2025-01-17
 */
@RestController
@RequestMapping("/food")
public class FoodController {

    @Autowired
    public FoodService foodService;

    @PostMapping("/findAllFood")

    public Result<List<Food>> findAll() {
        return Result.ok(foodService.list());
    }
    @PostMapping("/findFoodOrderByRating")
    public Result<List<Food>> findFoodOrderByRating(Integer rating) {
        List<Food> listAll = foodService.findFoodOrderByRating(rating);
        return Result.ok(listAll);
    }
    //根据id查询餐厅的详情
    @GetMapping("/findById/{foodId}")
    public Result<Food> findById(@PathVariable("foodId") Integer foodId) {
        Food food = foodService.getByFoodId(foodId);
        return Result.ok(food);
    }
    @PostMapping("/findVouchers")
    public Result<List<Vouchers>> findVouchers(Vouchers vouchers) {
        List<Vouchers> list = foodService.findVouchers(vouchers);
        return Result.ok(list);

    }
    @PostMapping("/findMeals")
    public Result<List<Meals>> findMeals(Meals meals) {
        List<Meals> list = foodService.findMeals(meals);
        return Result.ok(list);
    }
    @GetMapping("/findMealById")
    public Result<Meals> findMealById(@RequestParam("packageId") Integer packageId) {
        System.out.println(packageId);
        Meals meals = foodService.getMealById(packageId);
        return Result.ok(meals);
    }
}
